package com.gy.spark.core.transformations

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Operator_groupByKey {

  def main(args: Array[String]): Unit = {


    val conf = new SparkConf().setAppName(this.getClass.getSimpleName).setMaster("local")
    val sc = new SparkContext(conf)

    val rdd1 = sc.makeRDD(Array(
      (1, "a"),
      (1, "b"),
      (2, "c"),
      (3, "d")
    ))
    val value: RDD[(Int, Iterable[String])] = rdd1.groupByKey(3)
    value.foreach(println)


    sc.stop

  }
}
